<?php

use think\facade\Route;

#base
Route::get('/', static function () {
    return json(['msg' => 'welcome!', 'code' => 0], 200);
});
Route::miss(static function () {
    return json(['msg' => 'resource is not found！', 'code' => -1], 404);
});

#test
Route::get('test/test', 'admin/Test/test');

#admin
##rbac
Route::group('rbac', function () {
    #group
    Route::get('group/list', 'admin/Rbac/getRbacGroupList');
    Route::post('group', 'admin/Rbac/postRBACGroup');
    Route::put('group', 'admin/Rbac/putRbacGroup');
    Route::delete('group', 'admin/Rbac/deleteRBACGroup');

    #role
    Route::get('role/list', 'admin/Rbac/getRBACRoleList');
    Route::post('role', 'admin/Rbac/postRBACRole');
    Route::put('role', 'admin/Rbac/putRBACRole');
    Route::delete('role', 'admin/Rbac/deleteRBACRole');

    #group_role
    Route::post('group_role', 'admin/Rbac/postRBACGroupRole');
});

##admin
Route::post('login', 'admin/Admin/login');
Route::get('info', 'admin/Admin/getAdminInfo');
Route::put('password', 'admin/Admin/putPassword');

##media
Route::group('media', function () {
    Route::get('list', 'admin/Media/getMediaList');
    Route::post('image', 'admin/Media/postImage');
    Route::delete('image', 'admin/Media/deleteImage');

    Route::post('video', 'admin/Media/postVideo');
    Route::delete('video', 'admin/Media/deleteVideo');
});

##Article
Route::group('article', function () {
    Route::get('list', 'admin/Article/getArticleList');
    Route::post('', 'admin/Article/postArticle');
    Route::put('', 'admin/Article/putArticle');
    Route::delete('', 'admin/Article/deleteArticle');
});

Route::get('system/backup', 'admin/System/getBackupList');
Route::post('system/backup', 'admin/System/postBackup');
Route::put('system/backup', 'admin/System/putBackup');
Route::delete('system/backup', 'admin/System/deleteBackup');


//->allowCrossDomain([
//'Access-Control-Allow-Origin'        => '*',
//'Access-Control-Allow-Credentials'   => 'true'
//]);

